package com.ctu.gzero.properties
{	
	public class EnumStringProperty extends Property
	{
		private var _range:Object;
		
		public function EnumStringProperty(name:String, value:String)
		{
			 super(name, value);
			
			_range =  new Object();	
			var s:Object = _range;								
			var i:int = 0;		
							
			while(i < s.length)
			{
				_range[s[i]] = null;
				i++;
			}
			
		}
		
		public function get range():Object
		{
			return Property.shallowCopy(_range);
		} 	
		
		override public function hash(obj:Object, code:uint):uint
		{
			var tmp:Object = null;
			var _u:uint = 0;
			
			for(var s:Object in _range)
			{
				tmp = s;
				if(obj==tmp)
				{
					return UintProperty.doHash(_u,code);
				}
				else
				{
					_u++;
				}
				
			}
			
			return code;
		}	
		
		override public function setHelper(obj1:Object, obj2:Object):Object
		{
			if(obj2==null)
			{
				return obj2;
			}
			
			var tmp:Object =  _range.hasOwnProperty(obj2) ? obj2 : obj1;
			return tmp;
		}
	}
}

